package main

import (
	"gzstore/controller"
	"gzstore/dao"
	"gzstore/model"

	"github.com/gin-gonic/gin"
)

func main() {
	//初始化数据库
	err := dao.InitMySQL()
	if err != nil {
		panic(err)
	}
	defer dao.Close()

	dao.DB.AutoMigrate(&model.Book{})

	//开启gin
	r := gin.Default()

	//设置静态文件和模板文件
	r.Static("/static", "static")
	r.LoadHTMLGlob("pages/**/*")

	r.GET("/", controller.GetPageBooksByprice)
	r.GET("/getPageBooksByPrice", controller.GetPageBooksByprice)

	r.Run()

}
